#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=1e5+5,M=1e5+5;
int n,m,L,V;
int d[N],v[N],a[N],p[M];
int cnt=0;
struct node{
    int l,r;
}c[N];
bool ok[N];
inline int upper(int x){//>d[i]
    int l=1,r=m;
    while(l<r){
        int mid=(l+r)>>1;
        if(p[mid]>x) r=mid;
        else l=mid+1;
    }
    return l;
}inline int upper_e(int x){//>=d[i]
    int l=1,r=m;
    while(l<r){
        int mid=(l+r)>>1;
        if(p[mid]>=x) r=mid;
        else l=mid+1;
    }
    return l;
}
inline int lower(int x){//<d[i]
    int l=1,r=m;
    while(l<r){
        int mid=(l+r+1)>>1;
        if(p[mid]<x) l=mid;
        else r=mid-1;
    }
    return l;
}
inline void add(int l,int r){
    if(l<=r){
        cnt++;
        c[cnt]={l,r};
    }
}
bool cmp(node x,node y){
    if(x.l!=y.l) return x.l<y.l;
    return x.r<y.r;
}
inline bool jiao(int l1,int r1,int l2,int r2){
    if(l1>r1||l2>r2) return 0;
    if(l2>r1||l1>r2) return 0;
    return 1;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t;
    scanf("%d",&t);
    for(int o=1;o<=t;o++){
        scanf("%d%d%d%d",&n,&m,&L,&V);
        for(int i=1;i<=n;i++)
            scanf("%d%d%d",&d[i],&v[i],&a[i]);
        for(int i=1;i<=m;i++)
            scanf("%d",&p[i]);
        cnt=0;
        for(int i=1;i<=n;i++){
            if(a[i]==0){
                if(v[i]>V) add(upper_e(d[i]),m);
                continue;
            }
            int stop=d[i]+(V*V-v[i]*v[i])/(2*a[i]);
            if(a[i]>0){
                if(v[i]>V) add(upper_e(d[i]),m);
                else if(stop<p[m]){
                     add(upper(stop),m);
                }
                continue;
            }
            if(a[i]<0){
                if(v[i]>V) add(upper_e(d[i]),lower(stop));
                continue;
            }
        }
        printf("%d ",cnt);
        sort(c+1,c+cnt+1,cmp);
        int now=1,ans=0;
        while(now<=cnt){
            ans++;
            if(now==cnt) break;
            bool flag=0;
            int l=c[now].l,r=c[now].r;
            while(jiao(l,r,c[now+1].l,c[now+1].r)){
                l=max(l,c[now+1].l);
                r=min(r,c[now+1].r);
                now++;
                if(now==cnt){
                    flag=1;
                    break;
                }
            }
            if(flag) break;
        }
        printf("%d\n",m-ans);
    }
    return 0;
}
